import { instrction } from "../config.js";
const keys = Object.keys(instrction);

//作弊码
let currentInstrction = "";
export const instrctionFun = ({ key }: KeyboardEvent) => {
  currentInstrction += key;
  let len = currentInstrction.length;
  //判断当前字符串是否有匹配指令
  let flag = keys.some((k) => k.slice(0, len) === currentInstrction);
  //不符合就清空
  if (!flag) return (currentInstrction = "");
  keys.forEach((key) => {
    if (key === currentInstrction) {
      console.log(1);
      let a = instrction as any;
      a[key]();
      currentInstrction = "";
    }
  });
};
